<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MilestoneAdmin
 *
 * @author agama
 */
class MilestoneAdmin extends MilestonePost
{

    //put your code here

    function __construct()
    {
        parent::__construct();

        $this->levelable = ($this->id == $this->main_milestone);
        $this->closeable = $this->closed == 'N';
        $this->unclosable = $this->closed != 'N';
        $this->deletable = true;
    }

    function doPOST( Event $e )
    {
        if ( $e->tag == 'unclose' ) {
            if ( $this->unclosable ) {

                //$sql='UPDATE milestones SET updated=NOW(), closed=\'N\' WHERE id='.$this->id;
                //MyLink::$default->execute($sql);

                $sql = 'UPDATE milestones SET updated=NOW(), closed=\'N\' WHERE trace LIKE \'%.' . $this->id . '.%\'';
                MyLink::$default->execute( $sql );


                $this->notifyOwner( 'UNCLOSE' );
            }
            $e->cancelBubble();
        }
        else parent::doPOST( $e );
    }

}

?>
